package com.xiangha.springboot.controller;

import com.xiangha.springboot.service.impl.OrdersServiceImpl;
import com.xiangha.springboot.utils.JwtUtils;
import com.xiangha.springboot.utils.ResponseMsg;
import io.jsonwebtoken.Claims;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author itlong
 * @since 2025-09-19 03:40:35
 */
@RestController
public class OrdersController {
    @Autowired
    OrdersServiceImpl ordersService;
    @RequestMapping("/points/order-records")
    public ResponseMsg getOrderRecords(HttpServletRequest request) {
        String token=request.getHeader("token");
        System.out.println("当前登录的用户信息:"+token);
        if (token == null || token.isEmpty()) {
            return ResponseMsg.getInstance(401, "用户未登录");
        }
        Claims claims= JwtUtils.parseJWT(token);
        System.out.println("当前登录的用户信息11111:"+claims);
        System.out.println("当前登录的用户信息222222:"+ordersService.getPoints(claims.getId()));
        return ResponseMsg.getInstance(200,ordersService.getPoints(claims.getId()));
    }
}